// 1
import request from '@/utils/request.js'
// import store from '../store'

// 封装接口请求的方法
export const allChannelListAPI = () => {
  return request({
    url: '/v1_0/channels'
  })
}

// 接口声明和使用
// 用户 - 登录
export const loginAPI = ({ mobile, code }) => {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data: {
      mobile,
      code
    }
  })
}
// 频道 - 用户已选列表
export const userChannelAPI = () => request({
  url: '/v1_0/user/channels',
  headers: {
    // Authorization: 'Bearer ' + store.state.token
  }
})

// 获取新闻列表
export const articlesListAPI = ({ channelId, timestamp }) => {
  return request({
    url: '/v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp: timestamp || (new Date()).getTime()
    }
  })
}
// 不喜欢
export const articleDislikeAPI = ({ target }) => {
  return request({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: target
    },
    headers: {
      // Authorization: 'Bearer ' + store.state.token
    }
  })
}

// 文章 - 举报
export const articleReportsAPI = ({ target, type, remark }) => {
  return request({
    url: '/v1_0/article/reports',
    method: 'POST',
    data: {
      target: target,
      type: type,
      remark: remark
    },
    headers: {
      // Authorization: 'Bearer ' + store.state.token
    }
  })
}

// 频道更新
export const updateChannelAPI = ({ channels }) => {
  return request({
    url: '/v1_0/user/channels',
    method: 'PUT',
    data: {
      channels: channels
    }
  })
}

// 频道建议
export const suggestListAPI = ({ q }) => {
  return request({
    url: '/v1_0/suggestion',
    params: {
      q: q
    }
  })
}
